using System;
using System.Collections.Generic;
using System.Text;
using AccesoDatos;
using System.Data;
using ProductInterfaces;

namespace ProductBE
{
    public class Category : ICategory
    {
        private Manager __objMgr = null;

        public Category()
        {
            this.__objMgr = new Manager("conexion.xml"); 
        }

        public DataTable ReadAll()
        {
            DataTable lvDtbRet = null;
            try
            {
                this.__objMgr.Conectar();
                lvDtbRet = this.__objMgr.Leer("usps_Categories", null).Tables[0];
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to ReadAll categories.", ex);
            }
            finally
            {
                this.__objMgr.Desconectar();
            }
            return lvDtbRet; 
        }

        private int __intCatID = 0;

        public int CategoryID
        {
            get { return this.__intCatID; }
            set { this.__intCatID = value; }
        }

        public IProduct GetProduct()
        {
            Product lvProd = new Product(this.__intCatID);
            return lvProd;
        }
    }
}
